home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok24.lha
/
DME
/
SRC
/
source.zoo
/
cmd3.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-03
|
3KB
|
198 lines
/*
* CMD3.C
*
* (C)Copyright 1988 by Matthew Dillon, All Rights Reserved
*
* SETFONT
* IGNORECASE
* SET
* SETENV
* UNSET
* UNSETENV
* CD
*/
#include "defs.h"
#include <local/xmisc.h>
#include <stdio.h>
#define nomemory() { memoryfail = 1; }
extern FONT *GetFont();
/*
* SETFONT font size
*/
void
do_setfont()
{
register FONT *font = GetFont(av[1], atoi(av[2]));
register ED *ep = Ep;
if (font) {
if (ep->Font)
CloseFont(ep->Font);
ep->Font = font;
SetFont(ep->Win->RPort, font);
SetRast(ep->Win->RPort, 0);
RefreshWindowFrame(ep->Win);
set_window_params();
text_redisplay();
} else {
title("Unable to find font");
}
}
do_ignorecase()
{
register ED *ep = Ep;
if (av[1][0]) {
switch(av[1][1] & 0x1F) {
case 'n'&0x1F:
ep->IgnoreCase = 1;
break;
case 'f'&0x1F:
ep->IgnoreCase = 0;
break;
case 'o'&0x1F:
ep->IgnoreCase = 1 - ep->IgnoreCase;
break;
}
if (ep->IgnoreCase)
title("Case InSensitive");
else
title("Case Sensitive");
}
}
/*
* av[1]
*/
do_cd()
{
long oldlock;
long lock;
oldlock = CurrentDir(Ep->dirlock);
if (lock = Lock(av[1], SHARED_LOCK)) {
UnLock(CurrentDir(oldlock));
Ep->dirlock = lock;
} else {
CurrentDir(oldlock);
Abortcommand = 1;
title("Unable to CD");
}
}
/*
* VARIABLE SUPPORT!
*/
#define VARS struct _VARS
VARS {
MNODE Node;
char *Name;
char *Str;
};
static MLIST SList = { (MNODE *)&SList.mlh_Tail, NULL, (MNODE *)&SList.mlh_Head };
void
do_set()
{
register VARS *v;
do_unset();
if (v = malloc(sizeof(VARS))) {
if (v->Name = malloc(strlen(av[1])+1)) {
if (v->Str = malloc(strlen(av[2])+1)) {
AddHead(&SList, v);
strcpy(v->Name, av[1]);
strcpy(v->Str , av[2]);
return;
}
free(v->Name);
}
free(v);
}
nomemory();
}
do_setenv()
{
SetDEnv(av[1], av[2]);
}
do_unset()
{
register VARS *v;
for (v = (VARS *)SList.mlh_Head; v->Node.mln_Succ; v = (VARS *)v->Node.mln_Succ) {
if (strcmp(v->Name, av[1]) == 0) {
Remove(v);
free(v);
free(v->Name);
free(v->Str);
break;
}
}
}
do_unsetenv()
{
register char *ptr = (char *)av[1];
register char *tmp = malloc(4+strlen(ptr)+1);
if (tmp) {
strcpy(tmp, "ENV:");
strcat(tmp, ptr);
mountrequest(0);
DeleteFile(tmp);
mountrequest(1);
free(tmp);
}
}
/*
* Search (1) internal list, (2) enviroment, (3) macros. The variable
* is allocated with malloc(). NULL if not found. ENV: need not exist.
*/
char *
getvar(find)
char *find;
{
register char *str = NULL;
{
register VARS *v;
for (v = (VARS *)SList.mlh_Head; v->Node.mln_Succ; v = (VARS *)v->Node.mln_Succ) {
if (strcmp(v->Name, find) == 0) {
if (str = malloc(strlen(v->Str)+1)) {
strcpy(str, v->Str);
return(str);
}
}
}
}
mountrequest(0);
str = GetDEnv(find);
mountrequest(1);
if (str)
return(str);
if ((str = keyspectomacro(find)) || (str = menutomacro(find))) {
register char *ptr = malloc(strlen(str)+1);
if (ptr) {
strcpy(ptr, str);
return(ptr);
}
}
return(NULL);
}